local hx__fuquan = fk.CreateSkill {
  name = "hx__fuquan",
  tags = { Skill.Compulsory },
}


hx__fuquan:addEffect(fk.GameStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    return player:hasSkill(hx__fuquan.name) and (table.every(room:getOtherPlayers(player, false), function (p)
    return p.hp > player.hp end) and table.every(room:getOtherPlayers(player, false), function (p) return p.maxHp > player.maxHp end))
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, 1)
    room:recover{
      who = player,
      num = 1,
      skillName = hx__fuquan.name,
    }
  end,
})

hx__fuquan:addEffect(fk.Deathed, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    local room = player.room
    return player:hasSkill(hx__fuquan.name) and not player.dead and (table.every(room:getOtherPlayers(player, false), function (p)
    return p.hp > player.hp end) and table.every(room:getOtherPlayers(player, false), function (p) return p.maxHp > player.maxHp end))
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, 1)
    room:recover{
      who = player,
      num = 1,
      skillName = hx__fuquan.name,
    }
  end,
})


return hx__fuquan
